#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;

using ll = long long;
ll A[MAXN], B[MAXN];
struct Node {
  ll a, b;

  bool operator<(const Node &node) {
    int d1 = a - b;
    int d2 = node.a - node.b;
    return d1 < d2 || d1 == d2 && a < node.a;
  }
};

int main() {
  ll n, m;
  cin >> n >> m;

  vector<Node> bottle;

  for (int i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    bottle.push_back({a - b, a});
  }
  sort(bottle.begin(), bottle.end());

  ll ans = 0;
  for (auto v : bottle) {
    if (n <= 0)
      break;

    ll res = v.a;
    ll lim = v.b;

    if (n < lim)
      continue;
    ll dis = n - lim;
    ll cnt = (dis / res) + 1LL;
    ans += cnt;
    n -= cnt * res;
  }

  cout << ans << endl;
}
